﻿@model Think9.Models.RuleAutoEntity
@{ ViewBag.Title = "Edit";
    Layout = "~/Areas/Shared/_LayuiForm.cshtml"; }

<form class="layui-form">
    <input style="display: none" id="rpId" value="@ViewBag.rpId">
    <br />
    <div class="layui-form-item" style="text-align: center; vertical-align: middle; ">
        <div class="layui-inline" style="width:100px">
            <select id="Type" name="Type">
                <option value="1">表头</option>
                <option value="2">数据行</option>
            </select>
        </div>
        <div class="layui-inline" style="width:100px">
            <input type="text" name="orderNo" id="orderNo" placeholder="请输入序号" autocomplete="off" class="layui-input" maxlength="4" lay-verify="required|number">
        </div>
        <div class="layui-inline">
            <button class="layui-btn" lay-submit lay-filter="add">添加行</button>
            <input type="checkbox" id="continue" title="连续添加">
        </div>
    </div>
</form>

<script>
    layui.use(["form", "exLayer", "exUtils"], function () {
        let form = layui.form;
        let exLayer = layui.exLayer;
        let exUtils = layui.exUtils;

        let $ = layui.$;

        form.render();

        form.on("submit(add)", function (data) {
            exUtils.ajax("/SysStats/Report/AddReportRows", "post", { rpId: $("#rpId").val(), type: $("#Type").val(), order: $("#orderNo").val() }, true).done(function (response) {
                exLayer.greenTickMsg(response.message, function () {
                    parent.layui.table.reload('tableId', { url: "/SysStats/ReportRows/GetList?rpId=" + $(window.parent.document).find("#rpId").val() });

                    if ($("#continue").is(':checked')) {
                        var _OrderNo = Number($("#OrderNo").val()) + 1;
                        $("#OrderNo").val(_OrderNo);
                    }
                    else {
                        parent.layer.close(parent.layer.getFrameIndex(window.name));
                    }

                });
            }).fail(function (error) {
                console.log(error);
            });
            return false;
        });

    });
</script>